package org.credo.wsdl.cxf;

import org.apache.cxf.tools.java2ws.JavaToWS;

/**
 * <p>Description: 未成功!</p>
 * @author <a href="zhaoqianjava@qq.com">Credo</a>
 */
public class JavaToWsdl {

	private Class<?> className;
	public String[] args1,args2,args3;
	
	public JavaToWsdl(Class<?> className){
		this.className=className;
		
		//根据Hello.class生成Hello.wsdl,生成的wsdl文件放在resource目录下  
        args1=new String[]{"-wsdl","-d","./resource",this.className.getName()};  
        //根据Hello.class生成Hello.wsdl，生成的文件放在根目录下的.example下  
        args2=new String[]{"-wsdl","-cp", "./example",this.className.getName()};  
        // 根据Hello.class生成wsdl文件，文件命名为myHello.wsdl，放在根目录下  
        args3=new String[]{"-o","myHello.wsdl","-wsdl",this.className.getName()};    
	}
	
	
	/** 
     * 构造函数 
     * @param className 要生成WSDL的Java类 
     * @param wsdlFileName 要生成WSDL的文件名称（不包含扩展名） 
     */  
    public JavaToWsdl(Class<?> className,String wsdlFileName) {  
        this.className = className;   
          
        //根据Hello.class生成Hello.wsdl,生成的wsdl文件放在resource目录下  
        args1=new String[]{"-wsdl","-d","./resource",this.className.getName()};  
        //根据Hello.class生成Hello.wsdl，生成的文件放在根目录下的.example下  
        args2=new String[]{"-wsdl","-cp", "./example",this.className.getName()};  
        // 根据Hello.class生成wsdl文件，文件命名为myHello.wsdl，放在根目录下  
        args3=new String[]{"-o",wsdlFileName+".wsdl","-wsdl",this.className.getName()};  
    }  
  
    public void JavaToWsdl(String[] args){  
        JavaToWS javaToWS = new JavaToWS(args);  
        try {  
            javaToWS.run();  
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
    }  
  
    public static void main(String[] args) {  
    	JavaToWsdl java2WSDL = new JavaToWsdl(CXFHello.class);  
        java2WSDL.JavaToWsdl(java2WSDL.args1);  
    } 
	

}
